﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _3D_FileExplorer
{
    public abstract class Node
    {
        private string name; //name for example image.jpg
        float weight = 1.0f;
        string type;
        string shortname;
        string description;
       
        public Node(string name, float weight,string type,string shortname,string description)
        {
            this.name = name;
            this.weight = weight;
            this.type = type;
            this.shortname = shortname;
            this.description = description;
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
      
        public string Type
        {
            get { return type; }
            set { type = value; }
        }
        public string ShortName
        {
            get { return shortname; }
            set { shortname = value; }
        }
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        public float Weight
        {
            get { return weight; }
            set { weight = value; }
        }

        public abstract String PrintRoot();

        public abstract String PrintIndent(String indent);


        public String PrintTree()
        {
            return PrintIndent("");
        }
    }

    public class InnerNode : Node
    {
        private List<Node> branch = new List<Node>(); // subdirectory
       
        public InnerNode(string name, float weight,string type,string shortname,string description) : base(name, weight, type,shortname, description)
        {
        }
      
        public List<Node> Branch
        {
            get { return branch; }
            set { branch = value; }
        }

        public override String PrintRoot()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<").Append(ShortName).Append(">");
            return sb.ToString();
        }
                
        public override String PrintIndent(String indent)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(indent).AppendLine(PrintRoot());
            String ind2 = indent + "  ";
            foreach (Node nd in Branch)
            {
                sb.Append(ind2).Append(nd.PrintIndent(ind2));
            }
            return sb.ToString();
        }


    }


    public class LeafNode : Node
    {

        public LeafNode(string name, float weight, string type, string shortname, string description) : base(name, weight, type, shortname, description) {}
        
        public override String PrintRoot()
        {
            return ShortName;
        }

        public override String PrintIndent(String indent)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(indent).AppendLine(PrintRoot());
            return sb.ToString();
        }

    }
}
